Skip to content

Conversation

ritamerkl
Copy link
Collaborator

@ritamerkl ritamerkl commented Oct 1, 2025

Description

This PR fixes an issue where InputSystem.anyButtonPress is triggered multiple times if another control of the same device is actuated while holding a button down. This is also reproducible on gamepads that receive events constantly, holding a button down then produces one anyButtonPress event per frame.

This was due to the fact that all controls of the device contained in the event were checked for actuated buttons, not only the control triggering the event. Then the magnitude check of the button causes the trigger of the callback over and over again.
This is prevented by the newly added line of code which checks if the control is the same as from the InputEvent.

This issue is fixed with the PR too.

Testing status & QA

Manual testing with Test project of customers.

Overall Product Risks

Low

  • Complexity: Low
  • Halo Effect: Low

Comments to reviewers

The documentation states that the callback is only triggered once per button press.

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

@codecov-github-com
Copy link

codecov-github-com bot commented Oct 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

@@             Coverage Diff             @@
##           develop    #2249      +/-   ##
===========================================
+ Coverage    76.70%   76.72%   +0.01%     
===========================================
  Files          465      465              
  Lines        87919    87944      +25     
===========================================
+ Hits         67442    67471      +29     
+ Misses       20477    20473       -4     
Flag Coverage Δ
inputsystem_MacOS_2021.3 5.91% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_2021.3_project 78.07% <100.00%> (+0.01%) ⬆️
inputsystem_MacOS_2022.3 5.37% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_2022.3_project 74.60% <100.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.0 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 76.52% <100.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.2 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.2_project 76.52% <100.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.3 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 76.52% <100.00%> (+0.01%) ⬆️
inputsystem_MacOS_6000.4 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4_project 76.52% <100.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_2021.3 5.91% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_2021.3_project 77.98% <100.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_2022.3 5.38% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_2022.3_project 74.41% <100.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.0 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 76.33% <100.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.2 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.2_project 76.33% <100.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.3 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 76.33% <100.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.4 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4_project 76.33% <100.00%> (+0.01%) ⬆️
inputsystem_Windows_2021.3 5.91% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_2021.3_project 78.22% <100.00%> (+0.01%) ⬆️
inputsystem_Windows_2022.3 5.37% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_2022.3_project 74.74% <100.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.0 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 76.66% <100.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.2 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.2_project 76.66% <100.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.3 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 76.66% <100.00%> (+0.01%) ⬆️
inputsystem_Windows_6000.4 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4_project 76.66% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Assets/Tests/InputSystem/CoreTests_Events.cs 98.49% <100.00%> (+0.02%) ⬆️
...tem/InputSystem/Controls/InputControlExtensions.cs 77.02% <100.00%> (+1.12%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@jfreire-unity jfreire-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a simple one liner and good to have yet another test for this!


[Test]
[Category("Events")]
public void Events_OnAnyButtonPressed_FiltersOutOtherControls()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to have a test. I assume this test would fail before your change, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

Copy link
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for looking into this.

@Pauliusd01
Copy link
Collaborator

Did not forget this one, taking a look today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants